<?php
/* @var $this Ajde_Template_Parser_Phtml_Helper */
?>

<h2>Edit shopping cart</h2>

<?php echo $this->ACAjaxForm('shop/cart:edit', null, 'editCart', 'body'); ?>

<input type='hidden' name='update' value='1' />

<table class='cart'>
	<colgroup>		
		<col />
		<col width="100" />
		<col width="150" />
		<col width="100" />
		<col width="50" />
	</colgroup>
	<thead>
		<tr>			
			<th>Description</th>
			<th>Unit price</th>
			<th>Quantity</th>
			<th>Total incl. VAT</th>
		</tr>
	</thead>
	<tbody>
		<?php if ($this->items->length() === 0) { ?>
			<tr>
				<td colspan='4'>
					<a href='shop'>Do some shopping</a>, <?php echo __('your cart is empty'); ?><br/>&nbsp;
				</td>
			</tr>
		<?php } ?>
		<?php foreach($this->items as $item) { 
			/* @var $item CartItemModel */ ?>
			<tr>				
				<td>
					<a href='<?php echo $item->getEntity()->getTable() . '/view/' . $item->getEntity()->getPK() . '.html'; ?>'>
						<?php echo $item->getDescription(); ?>
					</a>
				</td>
				<td>€ <?php echo money_format('%!i', $item->getUnitprice() * (1+$item->getVATPercentage())); ?></td>
				<td>
					<input type='number' class='qty' name='qty[<?php echo $item->getPK(); ?>]' value='<?php echo $item->getQty(); ?>' />
					<input type='button' value='Update' />
				</td>
				<td><?php echo $item->getFormattedTotal(); ?></td>
				<td><a href='javascript:void(0);' class='delete' data-id='<?php echo $item->getPK(); ?>'><?php echo __('delete'); ?></a></td>
			</tr>
		<?php } ?>
		<tfoot>
			<tr>
				<td colspan='2'><?php echo __('Total'); ?></td>
				<td></td>
				<td><?php echo $this->items->getFormattedTotal(); ?></td>
				<td></td>
			</tr>
		</tfoot>
	</tbody>
</table>

</form>

<?php if ($this->items->length() !== 0) { ?>
<div class='toolbar'>
	<a class='action' href='shop/checkout'>Checkout</a>
</div>
<?php } ?>